<div class="modal-body pageContent" style="overflow: scroll;">
	<div class="row">
        <div class="col-lg-12 col-md-12">
            
            <form action="/order/addOrder" enctype="multipart/form-data" method='post' id="orderForm">
                <div class="form-row">
                    <div class="form-group col-md-6 prl15">
                        <label class=" control-label" ><span class="indicator">*</span><span class="indicatorName">订单号</span></label>
                            <input type="text" class="form-control " name="orderId" />
                    </div>
                    <div class="form-group col-md-6 prl15">
                        <label class=" control-label " ><span class="indicator">*</span><span class="indicatorName">设备数目</span></label>
                            <input type="text" class="form-control" name="deviceNum" />
                    </div>
                </div>
                <div class="form-row prl10">
                    <div class="form-group col-md-12 ">
                        <label class=" control-label " >水司号</label>
                        <div class="row">
                                <div class="col-sm-6 prl15"  style="padding-left: 0px !important;" >
                                    <input type="text" class="form-control beginWaterDivision"  name="beginWaterDivision"  placeholder="开始水司号" id="beginWaterDivision" />
                                </div>
                                <div class="col-sm-6 prl15"  style="padding-right: 0px !important;">
                                    <input type="text" class="form-control endWaterDivision" name="endWaterDivision"  placeholder="结束水司号" id='endWaterDivision' />
                                </div>
                        </div>
                        <div class="row alarm" style='color:#a94442;'>
                                <div class="col-sm-12 prl15" >
                                  <span >开始水司号和结束水司号必须同时填写或者不填写</span>
                                </div>
                        </div>
                    </div>
                 </div>
                <div class="form-row">
                    <div class="form-group col-md-6 prl15">
                        <label class=" control-label " >客户</label>
                            <input type="text" class="form-control "  name="customer"   />
                    </div>
                    <div class="form-group col-md-6 prl15">
                        <label class=" control-label " >固件版本</label>
                            <input type="text" class="form-control"  name="firmwareVersion"/>
                    </div>
                </div>
                <div class="form-row">
                    <div class="form-group col-md-6 prl15" >
                        <label class=" control-label " ><span class="indicator">*</span><span class="indicatorName">软件版本</span></label>
                            <input type="text" class="form-control "  name="softwareVersion"   />
                    </div>
                    <div class="form-group col-md-6 prl15" >
                        <label class=" control-label " ><span class="indicator">*</span><span class="indicatorName">硬件版本</span></label>
                            <input type="text" class="form-control"  name="hardwareVersion"/>
                    </div>
                </div>
                <div class="form-row">
                    <div class="form-group col-md-6 prl15" >
                        <label class="col-lg-12 control-label" style="padding-left: 0px !important;">母线</label>
                        <div class="col-lg-12" style="padding-left: 0px !important;">
                            <input type="file" name="busFile" />
                        </div>
                    </div>
                    <div class="form-group col-md-6 prl15">
                        <label class=" control-label " ><span class="indicator">*</span><span class="indicatorName">工序集</span></label>
                            <select id="processCollectionId" class="selectpicker show-tick form-control" name="processSchemeId">
                                <option value=""  selected  style="display:none">请选择工序集</option>
                            </select>
                    </div>
                </div>
                <div class="form-row">
                    <div class="form-group col-md-6 prl15">
                        <label class=" control-label " ><span class="indicator">*</span><span class="indicatorName">产品配置</span></label>
                            <select id="productConfigCollectionId" class="selectpicker show-tick form-control" name="configId">
                                <option value=""  selected  style="display:none">请选择产品配置</option>
                            </select>
                    </div>
                    <div class="form-group col-md-6 prl15">
                        <label class=" control-label " ><span class="indicator">*</span><span class="indicatorName">产品类型</span></label>
                            <select id="productTypeCollectionId" class="selectpicker show-tick form-control" name="productType">
                                <option value=""  selected  style="display:none">请选择产品类型</option>
                            </select>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="modal-footer pageFooter">

    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
    <button  class="btn btn-primary"  type="submit" >保存</button>  
    
</div>
<script type="text/javascript">

$(document).ready(function() { 
    
    $('.selectpicker').selectpicker();//初始化
    $('#orderForm')
        .bootstrapValidator({
            message: '此值无效',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                orderId: {
                    validators: {
                        notEmpty: {
                            message: '请填写订单号'
                        },
                        regexp:{
                            regexp: /^[a-zA-Z0-9_]{0,15}$/,
                            message:"订单号只能由字母数字下划线组成，长度不得超过15个字符"
                        }
                    }
                },
                deviceNum: {
                    validators: {
                        notEmpty: {
                            message: '请填写设备数目'
                        },
                        regexp:{
                            regexp: /^[0-9]*$/,
                            message:"设备数目只能是字母"
                        }
                    }
                },
                beginWaterDivision: {
                    validators: {
                        regexp: {
                            regexp: /^[a-zA-Z0-9]{0,12}$/,
                            message: 'SN只能由字母、数字组成,长度不得超过12个字符'
                        }
                    }
                },
                endWaterDivision: {
                    validators: {
                        regexp: {
                            regexp: /^[a-zA-Z0-9]{0,12}$/,
                            message: 'SN只能由字母、数字组成,长度不得超过12个字符'
                        }
                    }
                },
                softwareVersion: {
                    validators: {
                        notEmpty: {
                            message: '请填写软件版本'
                        },
                    }
                },
                hardwareVersion: {
                    validators: {
                        notEmpty: {
                            message: '请填写硬件版本'
                        },
                    }
                },
                processSchemeId:{
                    validators: {
                        notEmpty: {
                            message: '请选择工序集'
                        },
                    }
                },
                configId:{
                    validators: {
                        notEmpty: {
                            message: '请选择产品配置'
                        },
                    }
                },
                productType:{
                    validators: {
                        notEmpty: {
                            message: '请选择产品类型'
                        },
                    }
                }
            }
        })
        .on('success.form.bv', function(e) {
            console.log('1111111111111');
            e.preventDefault();
            var $form = $(e.target);
            var bv = $form.data('bootstrapValidator');

            var begin =   $('.beginWaterDivision').val();
            var end =   $('.endWaterDivision').val();
            if (begin==""&&end!=""||begin!=""&&end=="") {
                if($('.alarm')!=undefined){
                    $('.alarm').empty();
                }
             $('.alarm').html("两个输入框必须同时为空或者不为空!").css('margin-left',"10px");
             return false;
            }
            console.log( $form.serialize());
            //原有json格式下无法将文件传给后台
            // $.post($form.attr('action'), $form.serialize(), function(result) {
            //     if(result.statusCode =='200'){
            //          toastr.success(result.message+'!');
            //          $('#orderListAdd').modal('hide');
            //          $("#ArbetTable").bootstrapTable('refresh');
            //     }else{
            //         toastr.warning(result.message+'!');
            //          $('#orderListAdd').modal('hide');
            //          $("#ArbetTable").bootstrapTable('refresh');
            //     }               
            // }, 'json');
          
            var formData = new FormData($("#orderForm")[0]); //换成上面这种表单数据绿色提交，file格式识别不到 
            $.ajax({  
                  url: '/order/addOrder' ,  
                  type: 'POST',  
                  data: formData,  
                  async: false,  
                  cache: false,  
                  contentType: false,  
                  processData: false,  
                  success: function (result) { 
                    if(result.length===9371){   
                                location.href="/severError";
                        }else{  
                            var successStr = JSON.parse(result);
                            if(successStr.statusCode=="200"){
                                $('#orderListAdd').modal('hide');
                                toastr.success(successStr.message+'!');
                                $("#ArbetTable").bootstrapTable('refresh');
                            }else{                
                                // $('#orderListAdd').modal('hide');
                                toastr.warning(successStr.message+'!'); 
                                // $("#ArbetTable").bootstrapTable('refresh');
                            }
                        }
                  },  
                  error: function (result) {      
                    if(result.status===503||result.status===500){ 
                        $('#orderListAdd').modal('hide');
                        toastr.error("服务端数据异常"+'!');
                    }
                  }  
             }); 
        });
   getprocessCollection();
   getConfigCollection();
   getConfigTypeCollection();
});

function getConfigCollection(){
        $.ajax({
            url:'/order/getConfigList',
            type:'POST',
            dataType:'json',
            // data:{"schemeId":'{{schemeId}}'},
            success:function(json){
               $.each(json,function(i,item){
                     if(item.description!=""){
                   $('#productConfigCollectionId').append('<option value="'+item.id+'">'+item.name+'('+item.description+')'+'</optinon>');
                     }else{
                   $('#productConfigCollectionId').append('<option value="'+item.id+'">'+item.name+'</optinon>');
                     }
            })
            $('#productConfigCollectionId').selectpicker('render');
            $('#productConfigCollectionId').selectpicker('refresh');
            }
          })
    }

    function getConfigTypeCollection(){
        $.ajax({
            url:'/order/getTypeList',
            type:'POST',
            dataType:'json',
            // data:{"schemeId":'{{schemeId}}'},
            success:function(json){
               $.each(json,function(i,item){
                     if(item.operator!=""){
                   $('#productTypeCollectionId').append('<option value="'+item.id+'">'+item.name+'('+item.operator+')'+'</optinon>');
                     }else{
                   $('#productTypeCollectionId').append('<option value="'+item.id+'">'+item.name+'</optinon>');
                     }
              })
              $('#productTypeCollectionId').selectpicker('render');
              $('#productTypeCollectionId').selectpicker('refresh');
            }
          })
    }

    function getprocessCollection(){
          $.ajax({
            url:'/order/processList',
            type:'POST',
            dataType:'json',
            // data:{"schemeId":'{{schemeId}}'},
            success:function(json){
               $.each(json,function(i,item){
                         if(item.demo!=""){
                                    if(item.name=="{{'processSchemeEntity[name]'}}"){
                                       $('#processCollectionId').text(item.name+item.demo);
                                    };//填充值

                                   $('#processCollectionId').append('<option value="'+item.id+'">'+item.name+'('+item.demo+')'+'</optinon>');    
                         }else{
                                    // if(item.name=="{{'processSchemeEntity[name]'}}"){
                                       // $('#processCollectionId').text(item.name);
                                     // };//填充值
                                   $('#processCollectionId').append('<option value="'+item.id+'">'+item.name+'</optinon>');
                         }
            })
            $('#processCollectionId').selectpicker('render');
            $('#processCollectionId').selectpicker('refresh');
            }
          })
     }
</script>